#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
    char a[1000];
    char t;
    int f = strlen(a);
    int count = 0;
    gets_s(a);
    scanf("%c", &t);
    for (int i = 0; i < f; i++)
    {
        if (a[i] == t)
            count++;
        if ('A' < a[i] && a[i] < 'Z' && (a[i] + 32 == t))
        {
            count++;
        }
        if ('a' < a[i] && a[i] < 'z' && (a[i] - 32 == t))
        {
            count++;
        }
    }
    printf("%d", count);
}